<?php
class CategoryTwoModel
{
    public function __construct()
    {
        $this->db   = Yaf_Registry::get('db');
        $this->time = date("Y-m-d H:i:s",time());
    }
    
    public function selectCategoryTwo($start,$everyPage){
        $sql="select * from `category_two` limit {$start},{$everyPage}";
        return $this->db->query($sql);
    }

    public function getCategoryTwoInfo(){
        $sql="select * from `category_two` where  category_id=46";
        return $this->db->query($sql);
    }

    public function getAllCount()
    {
        $sql="select count(*) as `rows` from `category_two` ";
        return $this->db->query($sql);
    }

    public function getCategoryTwoNameById($id){
        $sql="select * from `category_two` where category_id='{$id}'";
        return $this->db->query($sql);
    }

    public function del($id) 
    {
        $sql = "delete from `category_two` where category_two_id='{$id}' ";
        return $this->db->query($sql);
    }

    public function add($info) 
    {
        $sql="insert into `category_two`(`name`,`sites_id`,`category_id`,`create_time`) values('{$info['name']}','{$info["sites_id"]}','{$info["category_id"]}',UNIX_TIMESTAMP('{$this->time}'))";
        return $this->db->query($sql);
    }

    public function edit($info, $id) 
    {
        $sql = "update `category_two` set `name`='{$info['name']}', `sites_id`='{$info['sites_id']}',`category_id`='{$info['category_id']}',`create_time`=UNIX_TIMESTAMP('{$this->time}') WHERE category_two_id='{$id}'";
        return $this->db->query($sql);
    }

}
?>